struct ListNode* deleteNode(struct ListNode* head, int val)
{
    struct ListNode* pre = head;
    struct ListNode* cur = head;
    while (cur->val != val)
    {
        pre = cur;
        cur = cur->next;
    }
    if (pre == cur)
    {
        head = head->next;
    }
    else
    {
        pre->next = cur->next;
    }

    cur = NULL;
    pre = NULL;

    return head;
    // write code here
}